import Vue from "vue";

import Vuex from "vuex";
import actions from "./actions.js";
import mutations from "./mutations.js";
import cart from "./modules/cart.js";
import shop from "./modules/shop.js";

Vue.use(Vuex);

// this.$store

const store = new Vuex.Store({
  state: {
    count: 5,
    gender: 1,
  },
  getters: {
    g1: () => 100,
    g2: () => 200,
    g3: (state, getters) => getters.g1 + getters.g2 + state.count,
    cnGender(state) {
      return { 1: "男", 2: "女" }[state.gender];
    },
  },
  mutations,
  actions,
  // 子文件夹
  modules: {
    cart,
    shop,
  },
});

export default store;
